package org.minproject.my_library_back.mapper;

import org.apache.ibatis.annotations.Mapper;
import org.minproject.my_library_back.domain.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;

/**
* @author Lenovo
* @description 针对表【user】的数据库操作Mapper
* @createDate 2024-11-21 09:11:46
* @Entity org.minproject.my_library_back.domain.User
*/
@Mapper
public interface UserMapper extends BaseMapper<User> {

    @Select("SELECT * FROM user")
    List<User> getUsers();

    @Insert("INSERT INTO user (user_id,user_name, user_password, user_power, user_picture) VALUES (#{user_id},#{user_name}, #{user_password}, #{user_power}, #{user_picture})")
    @Options(useGeneratedKeys = true, keyProperty = "user_id")
    int addUser(User user);

    @Delete("DELETE FROM user WHERE user_id = #{user_id}")
    int deleteUser(@Param("user_id") int user_id);

    @Update("UPDATE user SET user_name = #{user_name}, user_password = #{user_password}, user_power = #{user_power}, user_picture = #{user_picture} WHERE user_id = #{user_id}")
    int updateUser(User user);

    @Select("SELECT * FROM user WHERE user_id LIKE CONCAT('%', #{user_id}, '%')")
    List<User> getUsersByUserIdLike(@Param("user_id") int user_id);

}




